package by.grsu.hdm.devices;

import by.grsu.hdm.exception.IllegalInternalStateException;
import by.grsu.hdm.model.HomeDevice;
import by.grsu.hdm.model.IMediaPlayerAbility;
import by.grsu.hdm.model.IRemoteControl;
import by.grsu.hdm.media.FileAudioVideo;


public class MediaPlayer extends HomeDevice implements IMediaPlayerAbility, IRemoteControl{
	
	private boolean access = false;
	
	protected MediaPlayer() {
		defaultConfiguration();
	}
	
	public MediaPlayer(String id) {
		super(id); 
	}
	
	
	@Override
	public String play(FileAudioVideo file) {
		this.access=true;
		return (getDeviceId() + file.getMessage(file.getName(), file.getFormat()));
	}

	@Override
	public void buttonPlay() throws IllegalInternalStateException{
		if(access == false){
			throw new IllegalInternalStateException();
		}
		System.out.println("You press play. "+ getDeviceId() +" plays.");
	}

	@Override
	public void buttonPause() throws IllegalInternalStateException{
		if(access == false){
			throw new IllegalInternalStateException();
		}
		System.out.println("You press pause. "+ getDeviceId() +" suspended.");
	}

	@Override
	public void buttonStop() throws IllegalInternalStateException{
		if(access == false){
			throw new IllegalInternalStateException();
		}
		System.out.println("You press stop. "+ getDeviceId() +" stopped playing.");
	}



}